package main

import (
	"fmt"
	"github.com/go-orm/app"
	"github.com/go-orm/app/blog"
	"github.com/go-orm/app/shop"
	"github.com/go-orm/app/sui/dao"
	"github.com/go-orm/app/sui/service"
	"github.com/go-orm/app/user/controller"
	"github.com/go-orm/routers"
)

func main() {
	//https://www.cnblogs.com/marshhu/p/12955754.html
	var GContainer = app.GContainer
	GContainer.SetSingleton("lawsuitDao", &dao.LawsuitDao{})
	GContainer.SetSingleton("lawsuitService", &service.LawsuitService{})

	type CtrlFactory struct {
		Service *service.LawsuitService `inject:"lawsuitService"`
	}
	ctlFactory := &CtrlFactory{}
	GContainer.Entry(ctlFactory) //
	ctlFactory.Service.Add()
	fmt.Println("22222222")



	routers.IncludeRouters(shop.Routers, blog.Routers,controller.Routers)
	// 初始化路由
	r := routers.Init()
	if err := r.Run(); err != nil {
		fmt.Printf("startup service failed, err:%v\n", err)
	}



}
